/**
 * Copyright 2019 [shujiang.yang], Inc. All rights reserved.
 * Email: 314938230@qq.com
**/
define("pages/snjy/snjy_dynamic", [
        "../../common/componts.js",
        "../../plugins/easyui/jquery-easyui-1.5.1/jquery.easyui.min",
        "../../plugins/easyui/jquery-easyui-1.5.1/easyloader",
        "../../plugins/artTemplate/artTemplate"
    ],
    function(require) {
        var componts = require("../../common/componts");
        //var queryTableId="awdDynamicQueryTableId";
        var selectid;

       var getQueryDataGrid = function(){
           return $("#"+queryTableId);
       };

        /**
         * 数据列表刷新加载
         */
        var loadDataGrid = function(){
            var formData = $(".awd-dynamic-query-form").serializeObject();
//            console.log("---------------");
//            console.log('form data -> ',formData);
//            console.log("---------------");
           // var queryParams = $.extend({},formData,{"state":"R2"});
            var queryParams = $.extend({},formData,{
                // "processDefinitionKey":componts.getUrlParam("processDefinitionKey"),
                // "taskDefinitionKey":componts.getUrlParam("taskDefinitionKey"),
                // "pageSize":function () {
                //     return getQueryDataGrid().datagrid("getPager").pagination("options").pageSize;
                //     return getQueryDataGrid().datagrid("getPager").pagination("options").pageSize;
                // },
                // "pageIndex":function () {
                //     return getQueryDataGrid().datagrid("getPager").pagination("options").pageNumber;
                // }
            });
            $.ajax({
                type : "POST",
                url : '/xxxx/dynamic',
                data : queryParams,
                success : function(result) {
                    console.log(result);
                    if (result.success) {
                        $.messager.alert("确定","数据加载成功","info");
                    }else{
                        $.messager.alert("确定","数据加载失败","warn");
                    }
                },
                complete:function(){
                }
            });
        };

        var bindAction=function(){
            //查询
            $(".awd-dynamic-query-btn").on("click",function(){
                loadDataGrid();
            });

            /**
             * 绑定回车事件
             */
            $(window).keydown(function(event) {
                if (event.keyCode == 13) {
                    loadDataGrid();
                }
            });

        };

        //初始化
        (function(){
            componts.initSelectPage(undefined);
            componts.initSelect(undefined,undefined,undefined);
            //tableInit();
            bindAction();
        })()
    });
